<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理</title>

    <script src="__STATIC__/jquery-2.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    {include file="public/header" /}
    {include file="public/left" /}
    <style>
        .layui-table-cell{
            height: 33px;
        }
    </style>



    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <fieldset class="layui-elem-field layui-field-title"  style="margin-top: 50px;">
                <legend>起始治疗方案</legend>
            </fieldset>


           <!-- <div class="demoTable">

                <button class="layui-btn" data-type="reload">搜索</button>
            </div>-->


            <form class="layui-form" action="">





                <div class="layui-form-item">


                    <div class="layui-inline">
                        <label class="layui-form-label">用户id</label>
                        <div class="layui-input-inline">
                            <input type="text" name="uid" id="uid" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">用户名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="username" id="username" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">就诊医院</label>
                        <div class="layui-input-inline">
                            <select name="hospital" id="hospital">
                                <option value=""></option>

                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">胰岛素类型</label>
                        <div class="layui-input-inline">
                            <select name="insulin" id="insulin" >
                                <option value=""></option>
                                <option value="1">速效胰岛素（超短效胰岛素）</option>
                                <option value="2">短效胰岛素（常规胰岛素）</option>
                            </select>
                        </div>
                    </div>



                    <button class="layui-btn" id="searchbtn" data-type="reload">搜索</button>
                </div>

            </form>




            <table class="layui-hide" id="list"></table>



            <script>
                layui.use('table', function(){
                    var table = layui.table;

                    table.render({
                        elem: '#list'

                        ,url: "{:url('treat/treatlistjson')}"
                        ,cols: [[
                            {type:'checkbox',width:'2%'}
                            ,{field:'brid', width:'10%', title: 'ID', sort: true}
                            ,{field:'username', width:'10%', title: '用户名'}
                            ,{field:'hospital', width:'10%', title: '就诊医院'}
                            ,{field:'insulin', width:'15%', title: '胰岛素类型'}
                            ,{field:'insulinamountday', width:'10%', title: '每天胰岛素总量(u)', sort: true}
                            ,{field:'baseinsulin', width: '10%', title: '基础率总量(u)' , sort: true}
                            ,{field:'beforeeatinsulin', width:'10%', title: '餐前大剂量总量(u)', sort: true}
                            ,{field:'operation', width:'22%', title: '操作',templet: '#operation'}
                        ]]
                        ,page: true
                        ,id:'tb'
                    });


                    var $ = layui.$, active = {
                        reload: function(){
                            var hospital = $('#hospital');
                            var uid = $('#uid');
                            var insulin = $('#insulin');
                            var username = $('#username');

                            //执行重载
                            table.reload('tb', {
                                page: {
                                    curr: 1 //重新从第 1 页开始
                                }
                                ,where: {
                                    key: {
                                        hospital: hospital.val(),
                                        uid: uid.val(),
                                        insulin: insulin.val(),
                                        username: username.val()
                                    }
                                }
                            });
                        }
                    };

                    $('#searchbtn').on('click', function(e){
                        e.preventDefault();
                        var type = $(this).data('type');
                        active[type] ? active[type].call(this) : '';
                    });

                });
            </script>
            <script type="text/html" id="operation">
                <a class="layui-btn layui-btn-normal" href="{:url('treat/treatment' )}?{literal}uid={{d.uid}} {/literal}" >详细</a>
                <a class="layui-btn layui-btn-danger delbtn"  onclick=" return confirm('你真的要删除这个新闻吗')" href="{:url('treat/delete' )}?{literal}brid={{d.brid}} {/literal}" >删除</a>
            </script>
        </div>
    </div>


</div>

<script>

    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
    $('#logout').click(function (e) {
        e.preventDefault();
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.confirm('你真的要退出吗？',['yes','no'],function () {
                location.href="{:url('login/logout')}";
            },function () {
                
            })
        });
    })





</script>

</body>
</html>